package mylib.dir;

import java.util.TreeMap;

/**
 * Created with IntelliJ IDEA.
 * User: 1
 * Date: 20.07.12
 * Time: 15:55
 * To change this template use File | Settings | File Templates.
 */
public class Counter64<K extends Comparable<K>> {
    private TreeMap<K, Long> data;

    public Counter64() {
        data = new TreeMap<K, Long>();
    }

    public long get(K key) {
        Long r = data.get(key);
        if (r == null)
            return 0L;
        return r;
    }

    public void add(K key, long by) {
        data.put(key, get(key) + by);
    }
}
